<template>
	<div class="refunding-wrapper">
    <!--正常退换货-->
    <div class="refunding-wrapper-good">
      <div class="good-list" v-for="goods in detailAll.goods" :key="goods.point_exchange_id">
        <div class="good-list-item">
          <div class="good-list-item-img">
            <img :src="goods.pic_url+'80x80'" width="80" height="80" v-if="goods.is_compress"/>
            <img :src="goods.pic_url" width="80" height="80" v-else/>
          </div>
          <div class="good-list-item-cont">
            <div class="title">{{ goods.title }}</div>
            <div class="center clearfix">
              <div class="txt fr">
                x{{ goods.num }}
              </div>
            </div>
            <div class="price"><span class="price">兑换{{detailAll.point_name || '积分'}}：{{ goods.point }}</span></div>
          </div>
        </div>
      </div>
    </div>
    <div class="refunding-wrapper-mone">
      <span>实付金额：</span>
      <span class="price" v-html="scaleGoodsPriceFn(detailAll.post_fee || '0.00')"></span>
    </div>   
      <div class="refunding-wrapper-check">
        <div class="refunding-wrapper-check-two">
          <div class="r-left"><span>退回{{detailAll.point_name || '积分'}}</span></div>
          <div class="r-right">{{ detailAll.points }}</div>
        </div>
        <div class="refunding-wrapper-check-two">
          <div class="r-left"><span>退款运费</span></div>
          <div class="r-right">{{mSymbol.name}}{{detailAll.post_fee || '0.00'}}</div>

        </div>
        <!-- <div class="refunding-wrapper-check-one">
          <div class="r-left"><span>退款原因</span></div>
          <div class="r-right" :class="showReason ? 'col3':''" @click="showReasonPicker=true"><span>{{showReason ? showReason:'请选择'}}</span><img src="https://img.wifenxiao.com/h5-wfx/images/refund/arrow_r.png" alt=""></div>
        </div> -->
      </div>
      <div class="refunding-wrapper-reason">
        <div class="r-left"><template v-if="detailAll.is_return_required">*</template><span>退款说明</span></div>
        <div class="r-right"><input type="text" v-model="tkReason"  placeholder="请输入退款说明"></div>
      </div>
      <!-- <div class="refunding-wrapper-img">
        <div class="title">上传凭证</div>
        <div class="box">
          <UploadImg ref="uploadImgChild" maxCount="maxCount" @uploadImgList="uploadImgListIssue" class="img-lists"></UploadImg>
        </div>
      </div> -->

      <div class="refunding-wrapper-btn" @click="postRefund">
        <div class="btn red-gra-btn"><span>提交申请</span></div>
      </div>
      <!-- <van-popup v-model="showReasonPicker" round position="bottom">
        <van-picker
          show-toolbar
          :columns="reasonColumns"
          @cancel="showReasonPicker = false"
          @confirm="onConfirmReason"
        />
      </van-popup> -->
  </div>
</template>

<script>
  /**
   * @Author: zhangmeng
   * @Date: 2020-06-29 20:04:56
   * @Last Modified by: zhangmeng
   * @Last Modified time: 2020-07-03 14:54:46
   */
  import { pointExchangeOrderDetail, applicationSubmission } from '@/api/user/member/memberApi.js'
  import { scaleGoodsPrice } from '@/utils/index.js'
  import UploadImg from '@/components/UploadImg'
  import Vue from 'vue'
  import { Picker, Popup } from 'vant'
  Vue.use(Picker)
  Vue.use(Popup)
  import { mapGetters } from 'vuex'
  export default {
    name: 'index',
    components: {
      UploadImg
    },
    data() {
      return {
        detailAll: {}
      }
    },
    methods: {
      scaleGoodsPriceFn(price) {
        return scaleGoodsPrice(price)
      },
      // 点击数据提交
      postRefund() {
        const sendData = {}
        sendData.id = this.$route.query.id
        sendData.code = this.detailAll.code
        if (this.detailAll.is_return_required) {
          if (!this.tkReason) {
            this.$Error('请输入退款说明')
            return
          }
        }
        sendData.refund_dec = this.tkReason
        this.$loadingWrap.show()
        applicationSubmission(sendData).then(res => {
          this.$loadingWrap.close()
          if (res.status === 1) {
            this.$Error(res.msg)
            setTimeout(() => {
              this.$JumpName(this, 'pointOrder', { type: 4 })
            }, 1000)
          } else {
            this.$Error(res.msg)
          }
        })
      },
      // 获取基本数据
      getOrderRefundingfFun(sendData) {
        this.$loadingWrap.show()
        pointExchangeOrderDetail(sendData).then(res => {
          this.$loadingWrap.close()
          if (res.status === 1) {
            this.detailAll = res.data
            document.title = (this.detailAll.point_name || '积分') + '订单退款'
          } else {
            this.$Error(res.msg)
          }
        })
      }
    },
    created() {
      const $query = this.$route.query
      const sendData = {}
      sendData.id = $query.id
      sendData.refunding = 1
      this.getOrderRefundingfFun(sendData)
    },
    computed: {
      // 获取自定义符号
      ...mapGetters(['mSymbol'])
    }
  }
</script>
<style lang="scss">
.refunding-wrapper{
  .van-uploader__upload,.van-uploader__preview-image{
      width:146px;
      height:146px;
      border-radius: 2px;
      border: 2px dotted #b6b6b6;
      background:#fff;
    }
    .van-uploader__upload {
      border: 0 !important;
    }
    .van-uploader__upload{
      background: url("https://img.wifenxiao.com/h5-wfx/images/refund/refund_icon3.png") center no-repeat;
      background-size: 100% 100%;
      .van-uploader__upload-icon{
        margin-top:20px;
        &::before{
          content:"";
        }
      }
    }
    .van-uploader__preview-delete{
      color: #F42B2B;
    }
    .good-list  {
      &:last-child {
        .good-list-item {
          border: none;
        }
      }
    }
}
@import "src/styles/mixin";
.refunding-wrapper {
  width: 100%;
  box-sizing: border-box;
  &-good {
    width: 100%;
    margin-bottom: 2px;
    .good-list {
      width: 100%;
      background: #fff;
      padding: 30px 30px 0;
      box-sizing: border-box;
      &-item {
        &.mgl0{
          margin-left: 0;
        }
        width: calc(100% - 30px);
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: flex-start;
        border-bottom: 1px solid #ededed;
        margin-left: 30px;
        padding-bottom: 30px;
        &-img {
          width: 180px;
          height: 180px;
          overflow: hidden;
          border-radius: 10px;
          margin-right: 14px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        &-cont {
          width: calc(100% - 194px);
          .title {
            font-weight: 500;
            min-height: 84px;
            margin-right: 50px;
            @include lineClamp(28px, 42px, 2);
            margin-bottom: 5px;
          }
          .center {
            width: 100%;
            margin-bottom: 5px;
            .sku {
              color: #999;
              font-size: 24px;
              font-weight: 500;
              width: 50%;
               @include lineClamp(24px, 1.4, 1);
            }
          }
        }
      }
    }
  }
  &-mone {
    width: 100%;
    padding: 0 30px;
    box-sizing: border-box;
    height: 92px;
    line-height: 92px;
    background: #fff;
    text-align: right;
    margin-bottom: 20px;
    font-size: 26px;
  }
  &-item {
    width: 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    padding: 38px 30px;

    box-sizing: border-box;
    align-items: center;
    &-img {
      width: 50px;
      height: 46px;
      margin-right: 31px;
      img {
        width: 100%;
        height: 100%;
      }
    }
    &-cont {
      p {
        &:first-child {
          font-weight: bold;
          font-size: 32px;
          margin-bottom: 19px;
        }
        &:last-child {
          font-size: 24px;
          color: #999;
        }
      }
    }
    &:last-child {
      margin-bottom: 0;
    }
  }
  
  &-check {
    margin-bottom: 20px;
    width: 100%;
    background:#fff;
    .refunding-wrapper-check-item{
      padding: 30px 35px;
    }
    &-one {
      width: 100%;
      padding: 30px 35px;
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      justify-content: space-between;
      background-color: #fff;
    }
    &-two {
      width: 100%;
      padding: 30px 35px;
      background-color: #fff;
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      justify-content: flex-start;
      .r-left {
        margin-right: 49px;
      }
      .r-right {
        font-size: 24px;
        color: #999;
        width: 75%;
        input {
          font-size: 26px;
          width: 100%;
        }
      }
    }
    .r-left {
      font-size: 26px;
      font-weight: 500;
    }
    .col3 {
      color: #333;
    }
    .r-right {
      font-size: 28px;
      color: #999;
      input {
        font-size: 28px;
        color: #333;
      }
      img {
        margin-left: 9px;
        width: 9px;
        height: 16px;
      }
    }
  }
  &-reason {
    width: 100%;
    padding: 30px 35px;
    background-color: #fff;
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    margin-bottom: 20px;
    .r-left {
      margin-right: 49px;
      font-size: 28px;
      font-weight: 500;
    }
    .r-right {
      font-size: 26px;
      width: 75%;
      input {
        width: 100%;
      }
    }
  }
  &-img {
    width: 100%;
    padding: 35px 30px 33px;
    background-color: #fff;
    box-sizing: border-box;
    .title {
      font-size: 28px;
      font-weight: 500;
      padding-bottom: 40px;
    }
    .box {
      &>ul {
        width: 100%;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        .item {
          width: 146px;
          height: 146px;
          margin-right: 20px;
          position: relative;
          .img {
            width: 100%;
            height: 100%;
          }
          .close {
            position: absolute;
            top: -14px;
            right: -14px;
            width: 28px;
            height: 28px;
          }
        }
      }
    }
  }

  &-btn {
    width: 100%;
    padding: 0 50px;
    margin: 50px 0;
    .btn {
      line-height: 92px;
      text-align: center;
      color: #fff;
      font-size: 32px;
      border-radius: 46px;
    }
  }
}

</style>
